package com.mallcloud.mall.mall.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mallcloud.mall.mall.api.entity.XglQRCodePaymentModel;
import com.mallcloud.mall.mall.api.entity.vo.XglQRCodePaymentVO;
import com.mallcloud.mall.mall.mapper.XglQRCodePaymentMapper;
import com.mallcloud.mall.mall.service.XglQRCodePaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 星光里商户二维码服务实现类
 */
@Slf4j
@Service
public class XglQRCodePaymentServiceImpl extends ServiceImpl<XglQRCodePaymentMapper, XglQRCodePaymentModel> implements XglQRCodePaymentService {

	@Override
	public Page pageQRCodePayment(Page<XglQRCodePaymentVO> page, XglQRCodePaymentModel dto) {
		Page<XglQRCodePaymentVO> resultPage = this.baseMapper.pageQRCodePayment(page, dto);
		resultPage.getRecords().forEach(x ->
				x.setLinkUrl(String.format("https://hy.wentsoft.com/?merchantCode=%d", x.getMerchantCode()))
		);
		return resultPage;
	}

	@Override
	public List<XglQRCodePaymentVO> listQRCodePayment(XglQRCodePaymentModel dto) {
		List<XglQRCodePaymentVO> resultList = this.baseMapper.pageQRCodePayment(dto);
		resultList.forEach(x ->
				x.setLinkUrl(String.format("https://hy.wentsoft.com/?merchantCode=%d", x.getMerchantCode()))
		);
		return resultList;
	}

}
